package com.lwm.newdate;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author liweimin
 * @date 2020/9/15 14:45
 * @description 线程不安全！！！！
 */
public class OldDate {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        Callable<Date> dateCallable = new Callable<Date>() {
            @Override
            public Date call() throws Exception {
                return format.parse("20200915");
            }
        };
        ExecutorService pool = Executors.newFixedThreadPool(10);
        List<Future<Date>> result = new ArrayList<>();
        for (int i = 0; i<10 ; i++){
            result.add(pool.submit(dateCallable));
        }
        for(Future<Date> future: result){
            System.out.println(future.get());
        }

    }
}
